#ifndef CASTAR_H_INCLUDED_
#define CASTAR_H_INCLUDED_

extern int TERRAIN_PASSABLE;
extern int TERRAIN_IMPASSABLE;
extern int TERRAIN_SOME_WHAT_PASSABLE;

typedef struct NodeStruct {
	int x;
	int y;
	double g,h;
	struct NodeStruct* parent;
	int parentsCount;
	int hashCode;
} Node;

typedef struct {
	int nodesCount;
	Node** nodes;
	int reachesDestination;
	Node* closestNode;
} Path;

typedef struct {
	int width;
	int height;
	int* terrain;
} Area;

extern Area area;
extern Path lastCalculatedPath; //stores result of last call to CAStar_calculatePath(...)

void CAStar_init(int areaWidth, int areaHeight);
void CAStar_resetPath(int clearArea);//resets data from last path calculation. Can optionally clear area. Area dimensions cannot be changed
void CAStar_calculatePath(int startX, int startY, int destinationX, int destinationY, int somewhatPassableCostMultiplicator);
void CAStar_editArea(int x, int y, int terrainType);
int CAStar_getTerrainAt(int x, int y);
void CAStar_printPath();//this function is costly (each call allocates and frees a number of chars roughly equal to area size)
void CAStar_free();

#endif
